import behaviors from "../../../../config/behaviors";
Component({
  behaviors: [behaviors],
  properties: {
    products: {
      type: Array,
      value: [],
      observer(newVal, oldVal, changedPath) {
        if (newVal && newVal.length > 0) {
        }
      }
    },
    tips: false
  },
  data: {},
  methods: {
    onImage(e) {
      const item = e.currentTarget.dataset.item
      wx.navigateTo({
        url: '/sub_product/pages/detail/index?id=' + item.product.id
      })
    },
    onChecked(e) {
      const item = e.currentTarget.dataset.item
      this.triggerEvent('onChecked', {
        item
      })
    },

    increment(e) {
      const item = e.detail.item
      this.triggerEvent('addItem', { item })
    },

    decrement(e) {
      const item = e.detail.item
      this.triggerEvent('subItem', { item })
    },

    changeQuantity(e) {
      const item = e.detail.item
      const quantity = e.detail.quantity
      this.triggerEvent('changeQuantity', { item, quantity })
    }
  }
});
